package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fileName := "/Users/jumao/go/src/go_code/go_learning/chapter12_document_function/123.txt"
	file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE, 0666)
	defer file.Close()
	if err != nil {
		fmt.Printf("open file err=%v\n", file)
	}
	str := "hello\n"
	wr := bufio.NewWriter(file)
	for i := 0; i < 5; i++ {
		wr.WriteString(strconv.Itoa(i) + "." + str)
	}
	//将缓存写入磁盘
	wr.Flush()
}
